from ansible.inventory.manager import InventoryManager
from ansible.inventory.host import Host
from ansible.vars.manager import VariableManager
from ansible.parsing.dataloader import DataLoader

__all__ = ['BaseHost', 'BaseInventory']


class BaseHost(Host):
    def __init__(self, host_data):
        """
        :param host_data: {
          "hostname":"",
          "ip": "",
              "port": "",
              # behind is not must be required
              "username": "",
              "password": "",
              "private_key": "",
              "become": {
                  "method": "",
                  "user": "",
                  "pass": "",
              }
              "groups": [],
              "vars": {},
          }
        }
        """
        self.host_data = host_data
        hostname = host_data.get('hostname') or host_data.get('ip')
        port = host_data.get('port') or 22
        super().__init__(hostname, port)
        self.__set_required_variables()
        self.__set_extra_variables()
